Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

297
Visualizações
Discord bot doesn't send welcome messages | JS

So I am stuck on the welcoming feature of my discord bot.

It doesn't send any message.

Here is the code for the welcome.js file:

module.exports = (client) => {
    client.on("guildMemberAdd", (member) => {
        
        const welcomechannel = '934868156399386676';
        const ruleschannel = '934877916041457774';

        const embed = new Discord.MessageEmbed()
        .setTitle(`New member has arrived!`)
        .setDescription(`Welcome to the server <@${member.id}>! Enjoy your stay and make sure to check our rules ${member.guild.channels.cache.get(ruleschannel).ToString()}! :slight_smile:`)
        .setColor('#0ed42a')
        .setTimestamp()
        client.channels.cache.getwelcomechannel.send(embed)
    })

here is the code for the index.js file:

onst { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

const config = require("./config.json");
const welcome = require("./welcome.js");

client.once('ready', () => {
    console.log("Your bot is online!");


    welcome(client);
});

client.login(config.token); 
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

the problem is both in the index.js and the welcome.js

first of all your not including GUILD_MEMBERS as an intent in index.js.

Your second issue in the welcome.js. getwelcomechannel is not a valid property of ChannelManager, so as @bedstorm said you can use the get() function and pass in the channel id. Your code in welcome.js should look like this

module.exports = (client) => {
    client.on("guildMemberAdd", (member) => {

        const welcomechannel = '934868156399386676';
        const ruleschannel = '934877916041457774';

        const embed = new Discord.MessageEmbed()
            .setTitle(`New member has arrived!`)
            .setDescription(`Welcome to the server <@${member.id}>! Enjoy your stay and make sure to check our rules <#${ruleschannel}>! :slight_smile:`)
            .setColor('#0ed42a')
            .setTimestamp()
        client.channels.cache.get(welcomechannel).send(embed);
    })
}

Then just add the GUILD_MEMBERS intent to your client

about 4 years ago · Juan Pablo Isaza Relatório

0

The problem is in this line:

client.channels.cache.getwelcomechannel.send(embed)

There are 2 issues, getwelcomechannel is not a function, and even if it was a function, you aren't calling it.

To fix this, you can use the .get() method on the collection of channels.

client.channels.cache.get(welcomechannel).send(embed)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda